#include<iostream>
#include<cstdio>
using namespace std;

int main(){
	freopen("candy.in", "r", stdin);
	freopen("candy.out", "w", stdout); 
	int n, l, r;
	cin >> n >> l >> r;
	int xmin = l/n;
	int xmax = r/n;
	int flag = false;
	int ans = 0;
	for(int i = n-1; i >= 0; i--){
		if(flag == true) break;
		for(int j = xmin; j <= xmax; j++){
			if(i+j*n >= l && i+j*n <= r){
				ans = i;
				flag = true;
			}
		}
	}
	cout << ans << endl;
	return 0;
}
